<!--
 * @author  dumeng
 案例题
-->
<template>
  <div class="question-anli">
    <el-form
      ref="anliform"
      :model="baseform"
      :rules="baserules"
      class="dataForm nomt"
      label-position="right"
      label-width="100px"
    >
      <el-row>
        <el-col :span="24">
          <el-form-item label="案例内容" prop="stem">
            <el-input
              v-model.trim="baseform.stem"
              :disabled="disabled"
              :rows="4"
              type="textarea"
              placeholder="请输入案例内容"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-checkbox v-model="orderFixed" class="order-fixed" :disabled="disabled">案例题试题顺序固定</el-checkbox>
        </el-col>
        <el-col :span="24" class="tip">
          <div>说明：如果设置了“案例题试题顺序固定”。该案例题下的试题顺序固定，不进行试题顺序混淆。</div>
        </el-col>
        <el-col :span="24">
          <el-form-item label="试题解析">
            <el-input
              v-model.trim="baseform.questionAnalysis"
              :rows="2"
              :disabled="disabled"
              type="textarea"
              placeholder="添加试题解析，便于更好的理解答案"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>

export default {
  name: 'Anli',
  props: {
    type: {
      type: String,
      default: '60'
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      baseform: {
        stem: '',
        questionAnalysis: ''
      },
      orderFixed: false,
      baserules: {
        stem: [
          { required: true, message: '请输入案例内容', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    getPostData() {
      let params = ''
      this.$refs.anliform.validate(valid => {
        if (valid) {
          const answer = {
            type: this.type
          }
          params = {
            answer: JSON.stringify(answer),
            stem: this.baseform.stem,
            questionNumber: 0,
            questionAnalysis: this.baseform.questionAnalysis
          }
        }
      })
      return params
    }
  }
}
</script>

<style lang="scss">
.question-anli {
  .options .el-form-item__content {
    display: flex;
    align-items: center;
    .el-input {
      width: 100%;
      margin-right: 20px;
    }
  }
  .order-fixed {
    margin: 10px 0;
    padding-left: 100px;
  }
  .tip {
    padding-left: 100px;
    padding-bottom: 10px;
    color: red;
    div {
      margin-top: 10px;
    }
  }
}
</style>
